
{-# LANGUAGE TypeOperators, TypeFamilies, DeriveDataTypeable  #-}
{-# LANGUAGE FlexibleContexts #-}

module Main where

import Data.Typeable
import Control.Monad.State

import ORel

-- имена свойств
data Name  = Name  deriving (Show, Typeable)
data Size  = Size  deriving (Show, Typeable)
data Color = Color deriving (Show, Typeable)

-- отношение
data SomeRelation = SomeRelation deriving (Show, Typeable)
data RoleOne = RoleOne deriving (Show, Typeable)
data RoleTwo = RoleTwo deriving (Show, Typeable)

type instance PlayerType SomeRelation RoleOne = (Name, String) ::: (Size,Int) ::: Nil
type instance PlayerType SomeRelation RoleTwo = (Name, String) ::: Nil


test = flip evalState emptyStorage $ do
    o1 <- newObject
    o1 <- store $ o1
        ... Name  := "Object1"
        ... Size  := (5 :: Int)
        ... Color := "(blue)"
    
    o2 <- newObject
    o2 <- store $ o2
        ... Name  := "Object2"
        ... Size  := (3.5 :: Double)
    
    r1 <- newRelation SomeRelation
    store $ r1
        .+. RoleOne := o1
        .+. RoleTwo := o2

    navigate o2 SomeRelation RoleTwo RoleOne


